home *** CD-ROM | disk | FTP | other *** search
/ Hot Super Models / Hot Super Models.iso / unix / x11 / xv200.tar / xv-2.00 / xv.h < prev    next >
C/C++ Source or Header  |  1992-01-02  |  35KB  |  1,082 lines

  1. /*
  2.  *  xv.h  -  header file for xv, but you probably guessed as much
  3.  * 
  4.  *  Author:    John Bradley, University of Pennsylvania
  5.  *                (bradley@cis.upenn.edu)
  6.  */
  7.  
  8. /*
  9.  * Copyright 1989, 1990, 1991, 1992 by John Bradley and 
  10.  *                       The University of Pennsylvania
  11.  *
  12.  * Permission to use, copy, and distribute for non-commercial purposes,
  13.  * is hereby granted without fee, providing that the above copyright
  14.  * notice appear in all copies and that both the copyright notice and this
  15.  * permission notice appear in supporting documentation. 
  16.  *
  17.  * The software may be modified for your own purposes, but modified versions
  18.  * may not be distributed.
  19.  *
  20.  * This software is provided "as is" without any expressed or implied warranty.
  21.  *
  22.  * The author may be contacted via:
  23.  *    US Mail:   John Bradley
  24.  *               GRASP Lab, Room 301C
  25.  *               3401 Walnut St.  
  26.  *               Philadelphia, PA  19104
  27.  *
  28.  *    Phone:     (215) 898-8813
  29.  *    EMail:     bradley@cis.upenn.edu       
  30.  */
  31.  
  32.  
  33. #define REVDATE   "Version 2.00  Rev: 1/2/92"
  34.  
  35.  
  36. /*************************************************/
  37. /* START OF MACHINE-DEPENDENT CONFIGURATION INFO */
  38. /*************************************************/
  39.  
  40. #ifdef __UMAXV__              /* for Encore Computers UMAXV */
  41. #include <sys/fs/b4param.h>   /* Get bsd fast file system params*/
  42. #endif
  43.  
  44.  
  45. /* AIX and SysV r4 (but not sgi or UMAXV) use dirent */
  46. #if   (defined(SVR4) && !defined(sgi) && !defined(__UMAXV__))  \
  47.     || defined(_IBMR2)
  48. #define DIRENT
  49. #endif
  50.  
  51.  
  52. /* include files */
  53. #include <stdio.h>
  54. #include <math.h>
  55. #include <ctype.h>
  56.  
  57.  
  58. /* include the appropriate string header file */ 
  59. #ifdef SVR4
  60. #include <string.h>
  61. #define index strchr
  62. #define rindex strrchr
  63. #else
  64. #include <strings.h>
  65. #endif
  66.  
  67.  
  68. #ifdef SVR4
  69. #define GETWD(x) getcwd(x, sizeof(x))
  70. #else
  71. #define GETWD(x) getwd(x)
  72. #endif
  73.  
  74.  
  75. #if defined(apollo)
  76. /* DomainOS 10.2 BSD4.3 version of str[r]chr is broken ([r]index works) */
  77. #define strchr index
  78. #define strrchr rindex
  79. #endif
  80.  
  81.  
  82. extern int   errno;             /* this SHOULD be in errno.h */
  83. extern char *sys_errlist[];     /* this SHOULD be in errno.h */
  84.  
  85. /* Convex and UMAXV don't have <memory.h> */
  86. #if !defined(__convexc__) && !defined(__UMAXV__)
  87. #include <memory.h>             /* for 'memset()' prototype */
  88. #endif
  89.  
  90.  
  91. /* lots of things don't have <malloc.h> */
  92. #if !defined(ibm032)                    &&                    \
  93.     !defined(__convexc__)               &&               \
  94.     !(defined(vax) && !defined(ultrix)) && \
  95.     !defined(mips)                      &&                      \
  96.     !defined(apollo) &&                    \
  97.     !defined(__UMAXV__)
  98.  
  99. #if defined(hp300) || defined(hp800)
  100. #include <sys/malloc.h>                /* it's in 'sys' on HPs*/
  101. #else
  102. #include <malloc.h>
  103. #endif
  104.  
  105. #endif
  106.  
  107.  
  108. #if defined(NEED_MEMROUTINES)
  109. #define memcpy(d,s,l) bcopy(s,d,l)
  110. #endif
  111.  
  112.  
  113. #include <X11/Xos.h>
  114. #include <X11/Xlib.h>
  115. #include <X11/Xutil.h>
  116. #include <X11/cursorfont.h>
  117. #include <X11/keysym.h>
  118. #include <X11/Intrinsic.h>
  119. #include <X11/Xatom.h>
  120. #include <X11/Xmd.h>
  121.  
  122.  
  123.  
  124. #if defined(NEEDSTIME) || defined(NEEDSDIR)
  125. #include <sys/types.h>    /* only include <sys/types.h> once */
  126. #endif
  127.  
  128. #ifdef NEEDSTIME
  129. #ifdef SVR4
  130. #include <sys/time.h>
  131. #else                    /* not SVR4 */
  132. #if !defined(sgi) && !defined(__UMAXV__)   /* sgi & UMAX don't have timeb.h */
  133. #include <sys/timeb.h>
  134. #endif                   /* not sgi */
  135. #endif                   /* not SVR4 */
  136.  
  137. #undef SIGCHLD           /* defined in both the Xos.h and signal.h */
  138. #include <signal.h>
  139. #if defined(sco) && !defined(NOTIMER)
  140. #include <sys/itimer.h>
  141. #endif
  142.  
  143. #ifndef  sigmask
  144. #define  sigmask(m)      (1 << ((m)-1))
  145. #endif
  146.  
  147. #endif                   /* NEEDSTIME */
  148.  
  149.  
  150. #ifdef NEEDSDIR
  151.  
  152. #ifdef sco
  153. #include <sys/ndir.h>   /* sco has sys/ndir.h */
  154. #else
  155. #ifndef ATT
  156. #include <sys/dir.h>    /* everybody else (except ATT) has sys/dir.h */
  157. #endif  /* ATT */
  158. #endif  /* sco */
  159.  
  160. #include <sys/param.h>
  161. #include <sys/stat.h>
  162.  
  163. #ifdef DIRENT
  164. #include <dirent.h>
  165. #endif
  166. #endif                  /* NEEDSTIME */
  167.  
  168. #include <varargs.h>
  169.  
  170. /* signal macros */
  171. #if defined(SVR4) && !defined(HPUX7)
  172. #define HOLD_SIG         sighold(SIGALRM)  /* block ALRM sig from occurring */
  173. #define RELEASE_SIG      sigrelse(SIGALRM)
  174. #define PAUSE_SIG        sigpause(SIGALRM) /* sleep until ALRM signal */
  175. #else
  176. #define HOLD_SIG         sigblock(sigmask(SIGALRM))
  177. #define RELEASE_SIG      sigblock(0)
  178. #define PAUSE_SIG        sigpause(0)
  179. #endif
  180.  
  181.  
  182. #ifdef __UMAXV__
  183. #undef  PAUSE_SIG
  184. #define PAUSE_SIG sigpause(SIGALRM)
  185. #endif
  186.  
  187.  
  188. #ifdef i386
  189. #define MAXPATHLEN    500
  190. #define UNCOMPRESS    "/usr/local/bin/uncompress"   /* uncompress program */
  191. #undef  HOLD_SIG
  192. #define HOLD_SIG      /* don't know how to handle signals  MWS 10/18/90 */
  193. #undef  RELEASE_SIG
  194. #define RELEASE_SIG   /* */
  195. #undef  PAUSE_SIG
  196. #define PAUSE_SIG     /* */
  197. #else  /* NOT i386 */
  198. #ifdef hpux
  199. #define UNCOMPRESS "/usr/bin/uncompress"   /* for uncompressing .Z files */
  200. #else /* hpux */
  201. #define UNCOMPRESS "/usr/ucb/uncompress"   /* for uncompressing .Z files */
  202. #endif /* hpux */
  203. #endif
  204.  
  205.  
  206. /*****************************/
  207. /* END OF CONFIGURATION INFO */
  208. /*****************************/
  209.  
  210.  
  211.  
  212.  
  213. #define PROGNAME  "xv"             /* used in resource database */
  214.  
  215. #define DEFINFOGEOM "-10+10"       /* default position of info window */
  216. #define DEFCTRLGEOM "+400+400"     /* default position of ctrl window */
  217. #define DEFGAMGEOM  "+10-10"       /* default position of gamma window */
  218.  
  219. #define INFOWIDE 500               /* (fixed) size of info window */
  220. #define INFOHIGH 250
  221.  
  222. #define CTRLWIDE 440               /* (fixed) size of control window */
  223. #define CTRLHIGH 305
  224. #define CTRL_LISTW   (330-70)
  225.  
  226. #define DIRWIDE  300               /* (fixed) size of directory window */
  227. #define DIRHIGH  420
  228.  
  229. #define MAXNAMES 1024   /* max # of files (more than this?  Get REAL!) */
  230.  
  231. /* strings in the INFOBOX (used in SetISTR and GetISTR) */
  232. #define NISTR         9    /* number of ISTRs */
  233. #define ISTR_INFO     0
  234. #define ISTR_WARNING  1
  235. #define ISTR_FILENAME 2
  236. #define ISTR_FORMAT   3
  237. #define ISTR_RES      4
  238. #define ISTR_CROP     5
  239. #define ISTR_EXPAND   6
  240. #define ISTR_COLOR    7
  241. #define ISTR_COLOR2   8
  242.  
  243. /* potential values of 'infomode', used in info box drawing routines */
  244. #define INF_NONE 0    /* empty box */
  245. #define INF_STR  1    /* just ISTR_INFO */
  246. #define INF_PART 2    /* filename, format, size and infostr */
  247. #define INF_FULL 3    /* INF_PART + clipping, expansion, colorinfo */
  248.  
  249.  
  250. /* buttons in the ctrl window */
  251. #define NBUTTS   27
  252. #define BNEXT    0
  253. #define BPREV    1
  254. #define BCROP    2
  255. #define BUNCROP  3
  256. #define BNORM    4
  257. #define BMAX     5
  258. #define BUP2     6
  259. #define BDN2     7
  260. #define BUP10    8
  261. #define BDN10    9
  262. #define BQUIT    10
  263. #define B4BY3    11
  264. #define BSAVE    12
  265. #define BROTL    13
  266. #define BINFO    14
  267. #define BGAMMA   15
  268. #define BASPECT  16
  269. #define BROTR    17
  270. #define BMAXPECT 18
  271. #define BACROP   19
  272. #define BSMOOTH  20
  273. #define BDITH    21
  274. #define BRAW     22
  275. #define BLOAD    23
  276. #define BDELETE  24
  277. #define BFLIPH   25
  278. #define BFLIPV   26
  279.  
  280.  
  281. /* buttons in the 'save' window */
  282. #define S_NBUTTS 2
  283. #define S_BOK    0
  284. #define S_BCANC  1
  285.  
  286.  
  287. /* buttons in the 'gamma' window */
  288. #define G_NBUTTS   23
  289. #define G_BAPPLY   0
  290. #define G_BNOGAM   1
  291. #define G_BRESET   2
  292. #define G_BCLOSE   3
  293. #define G_BUP_BR   4
  294. #define G_BDN_BR   5
  295. #define G_BUP_CN   6
  296. #define G_BDN_CN   7
  297. #define G_B1       8
  298. #define G_B2       9
  299. #define G_B3       10
  300. #define G_B4       11
  301. #define G_BSET     12
  302. #define G_BUNDO    13
  303. #define G_BREDO    14
  304. #define G_BCOLREV  15
  305. #define G_BRNDCOL  16
  306. #define G_BHSVRGB  17
  307. #define G_BCOLUNDO 18
  308. #define G_BRV      19
  309. #define G_BMONO    20
  310. #define G_BMAXCONT 21
  311. #define G_BGETRES  22
  312.  
  313.  
  314. /* constants for setting radio buttons in dirW */
  315. #define F_COLORS    0
  316. #define F_FORMAT    1
  317.  
  318. #define F_FULLCOLOR 0
  319. #define F_GREYSCALE 1
  320. #define F_BWDITHER  2
  321. #define F_REDUCED   3
  322.  
  323. #define F_GIF       0
  324. #define F_PM        1
  325. #define F_PBMRAW    2
  326. #define F_PBMASCII  3
  327. #define F_XBM       4
  328. #define F_SUNRAS    5
  329. #define F_PS        6
  330.  
  331. #ifdef HAVE_JPEG
  332. #define F_JPEG      7
  333. #endif
  334.  
  335.  
  336. /* definitions for page up/down, arrow up/down list control */
  337. #define LS_PAGEUP   0
  338. #define LS_PAGEDOWN 1
  339. #define LS_LINEUP   2
  340. #define LS_LINEDOWN 3
  341. #define LS_HOME     4
  342. #define LS_END      5
  343.  
  344. /* values 'epicmode' can take */
  345. #define EM_RAW    0
  346. #define EM_DITH   1
  347. #define EM_SMOOTH 2
  348.  
  349. /* things EventLoop() can return (0 and above reserved for 'goto pic#') */
  350. #define QUIT     -1    /* exit immediately  */
  351. #define NEXTPIC  -2    /* goto next picture */
  352. #define PREVPIC  -3    /* goto prev picture */
  353. #define NEXTQUIT -4    /* goto next picture, quit if none (used by 'wait') */
  354. #define LOADPIC  -5    /* load 'named' pic (from directory box) */
  355. #define NEXTLOOP -6    /* load next pic, loop if we're at end */
  356. #define DFLTPIC  -7    /* load the default image */
  357. #define DELETE   -8    /* just deleted pic.  load 'right' thing */
  358.  
  359.  
  360. /* possible values of 'rootMode' */
  361. #define RM_NORMAL  0     /* default X tiling */
  362. #define RM_TILE    1     /* integer tiling */
  363. #define RM_MIRROR  2     /* mirror tiling */
  364. #define RM_IMIRROR 3     /* integer mirror tiling */
  365. #define RM_CENTER  4     /* modes >= RM_CENTER centered on some sort of bg */
  366. #define RM_CENTILE 4     /* centered and tiled.  NOTE: equals RM_CENTER */
  367. #define RM_CSOLID  5     /* centered on a solid bg */
  368. #define RM_CWARP   6     /* centered on a 'warp-effect' bg */
  369. #define RM_CBRICK  7     /* centered on a 'brick' bg */
  370. #define RM_MAX     RM_CBRICK
  371.  
  372.  
  373. /* definitions of first char of dirnames[i] (filetype) */
  374. #define C_FIFO  'f'    /* FIFO special file */
  375. #define C_CHR   'c'    /* character special file */
  376. #define C_DIR   'd'    /* directory */
  377. #define C_BLK   'b'    /* block special file */
  378. #define C_LNK   'l'    /* symbolic link */
  379. #define C_SOCK  's'    /* socket */
  380. #define C_REG   ' '    /* regular file */
  381.  
  382.  
  383. /* random string-placing definitions */
  384. #define SPACING 3      /* vertical space between strings */
  385. #define ASCENT   (mfinfo->ascent)
  386. #define DESCENT  (mfinfo->descent)
  387. #define CHIGH    (ASCENT + DESCENT)
  388. #define LINEHIGH (CHIGH + SPACING)
  389.  
  390.  
  391. #define STDINSTR "<stdin>"
  392.  
  393.  
  394. #ifndef MAIN
  395. #define WHERE extern
  396. #else
  397. #define WHERE
  398. #endif
  399.  
  400. typedef unsigned char byte;
  401.  
  402. typedef struct { Window win;            /* window ID */
  403.          int len;               /* length of major axis */
  404.          int vert;              /* true if vertical, else horizontal */
  405.          int active;            /* true if scroll bar can do anything*/
  406.          int min,max;           /* min/max values 'pos' can take */
  407.          int val;               /* 'value' of scrollbar */
  408.          int page;              /* amt val change on pageup/pagedown */
  409.          int tpos;              /* thumb pos. (pixels from tmin) */
  410.          int tmin,tmax;         /* min/max thumb offsets (from 0,0) */
  411.          int tsize;             /* size of thumb (in pixels) */
  412.          unsigned long fg,bg;   /* colors */
  413.          void (*drawobj)();     /* redraws obj controlled by scrl*/
  414.          int uplit, dnlit;      /* true if up&down arrows are lit */
  415.            } SCRL;
  416.  
  417. typedef struct { Window win;            /* window ID */
  418.          int w,h;               /* size of window */
  419.          int active;            /* true if can do anything*/
  420.          int min,max;           /* min/max values 'pos' can take */
  421.          int val;               /* 'value' of dial */
  422.          int page;              /* amt val change on pageup/pagedown */
  423.          char *title;           /* title for this guage */
  424.          char *units;           /* string appended to value */
  425.          unsigned long fg,bg;   /* colors */
  426.          int rad, cx, cy;       /* internals */
  427.          int bx[4], by[4];      /* more internals */
  428.          void (*drawobj)();     /* redraws obj controlled by dial */
  429.            } DIAL;
  430.  
  431. typedef struct { Window win;            /* parent window */
  432.          int x,y,w,h;           /* size of button rectangle */
  433.          int lit;               /* if true, invert colors */
  434.          int active;            /* if false, stipple gray */
  435.          int toggle;            /* if true, clicking toggles state */
  436.          unsigned long fg,bg;   /* colors */
  437.          char *str;             /* string in button */
  438.          Pixmap pix;            /* use pixmap instead of string */
  439.          int pw,ph;             /* size of pixmap */
  440.          int style;             /* ... */
  441.          int fwidth;            /* width of frame */
  442.            } BUTT;
  443.  
  444.  
  445. typedef struct rbutt { Window        win;      /* parent window */
  446.                int           x,y;      /* position in parent */
  447.                char         *str;      /* the message string */
  448.                int           selected; /* selected or not */
  449.                int           active;   /* selectable? */
  450.                struct rbutt *next;     /* pointer to next in group */
  451.                unsigned long fg,bg;    /* colors */
  452.              } RBUTT;
  453.  
  454.  
  455. typedef struct cbutt { Window        win;      /* parent window */
  456.                int           x,y;      /* position in parent */
  457.                char         *str;      /* the message string */
  458.                int           val;      /* 1=selected, 0=not */
  459.                int           active;   /* selectable? */
  460.                unsigned long fg,bg;    /* colors */
  461.              } CBUTT;
  462.  
  463.  
  464. typedef struct mbutt { Window        win;      /* parent window */
  465.                int           x,y,w,h;  /* position in parent */
  466.                char         *title;    /* title string in norm state */
  467.                int           selected; /* item# selected, or -1 */
  468.                int           active;   /* selectable? */
  469.                char        **list;     /* list of strings in menu */
  470.                int           nlist;    /* # of strings in menu */
  471.                Pixmap pix;             /* use pixmap instd of string */
  472.                int pw,ph;              /* size of pixmap */
  473.                unsigned long fg,bg;    /* colors */
  474.                Window        mwin;     /* popup menu window */
  475.              } MBUTT;
  476.  
  477.  
  478. typedef struct { Window win;            /* window */
  479.          int x,y,w,h;           /* size of window */
  480.          unsigned long fg,bg;   /* colors */
  481.          char **str;            /* ptr to list of strings */
  482.          int   nstr;            /* number of strings */
  483.          int   selected;        /* number of 'selected' string */
  484.          int   nlines;          /* number of lines shown at once */
  485.          SCRL  scrl;            /* scrollbar that controls list */
  486.          int   filetypes;       /* true if filetype icons to be drawn*/
  487.          int   dirsonly;        /* if true, only dirs selectable */
  488.            } LIST;
  489.  
  490.  
  491. #define MAX_GHANDS 16   /* maximum # of GRAF handles */
  492.  
  493. #define N_GFB 6
  494. #define GFB_SPLINE 0
  495. #define GFB_LINE   1
  496. #define GFB_ADDH   2
  497. #define GFB_DELH   3
  498. #define GFB_RESET  4
  499. #define GFB_GAMMA  5
  500.  
  501. #define GVMAX 8
  502.  
  503. typedef struct {  Window win;          /* window ID */
  504.           Window gwin;         /* graph subwindow */
  505.           int    spline;       /* spline curve or lines? */
  506.           int    entergamma;   /* currently entering gamma value */
  507.           int    gammamode;    /* currently using gamma function */
  508.           double gamma;        /* gamma value (if gammamode) */
  509.           int    nhands;       /* current # of handles */
  510.           XPoint hands[MAX_GHANDS];   /* positions of handles */
  511.           byte   func[256];    /* output function of GRAF */
  512.           BUTT   butts[N_GFB]; /* control buttons */
  513.           u_long fg,bg;        /* colors */
  514.           char   *str;         /* title string */
  515.           char   gvstr[GVMAX+1];    /* gamma value input string */
  516.         } GRAF;
  517.  
  518. typedef struct {  int    spline;
  519.           int    entergamma;
  520.           int    gammamode;
  521.           double gamma;
  522.           int    nhands;
  523.           XPoint hands[MAX_GHANDS];
  524.           char   gvstr[GVMAX+1];
  525.         } GRAF_STATE;
  526.  
  527.  
  528. /* MACROS */
  529. #define CENTERX(f,x,str) ((x)-XTextWidth(f,str,strlen(str))/2)
  530. #define CENTERY(f,y) ((y)-((f->ascent+f->descent)/2)+f->ascent)
  531.  
  532. /* RANGE forces a to be in the range b..c (inclusive) */
  533. #define RANGE(a,b,c) { if (a < b) a = b;  if (a > c) a = c; }
  534.  
  535. /* PTINRECT returns '1' if x,y is in rect (inclusive) */
  536. #define PTINRECT(x,y,rx,ry,rw,rh) \
  537.            ((x)>=(rx) && (y)>=(ry) && (x)<=(rx)+(rw) && (y)<=(ry)+(rh))
  538.  
  539. /* MONO returns total intensity of r,g,b components */
  540. #define MONO(rd,gn,bl) (((rd)*11 + (gn)*16 + (bl)*5) >> 5)  /*.33R+ .5G+ .17B*/
  541.  
  542.  
  543.  
  544. /* X stuff */
  545. WHERE Display       *theDisp;
  546. WHERE int           theScreen;
  547. WHERE unsigned int  ncells, dispWIDE, dispHIGH, dispDEEP;
  548. WHERE unsigned int  vrWIDE, vrHIGH, maxWIDE, maxHIGH;
  549. WHERE Colormap      theCmap, LocalCmap;
  550. WHERE Window        rootW, mainW, vrootW;
  551. WHERE GC            theGC;
  552. WHERE unsigned long black, white, fg, bg, infofg, infobg;
  553. WHERE unsigned long hicol, locol;
  554. WHERE unsigned long blkRGB, whtRGB;
  555. WHERE Font          mfont, monofont;
  556. WHERE XFontStruct   *mfinfo, *monofinfo;
  557. WHERE Visual        *theVisual;
  558. WHERE Cursor        arrow, cross;
  559. WHERE Pixmap        iconPix, iconmask;
  560.  
  561. /* global vars used by LOAD routines */
  562. WHERE byte          *pic;                   /* ptr to loaded picture */
  563. WHERE int            pWIDE,pHIGH;           /* size of 'pic' */
  564. WHERE byte           r[256],g[256],b[256];  /* colormap */
  565. WHERE char          *cmd;                   /* program name for printf's */
  566. WHERE int            DEBUG;                 /* print debugging info */
  567. WHERE int            mono;                  /* true if displaying grayscale */
  568. WHERE char           formatStr[80];         /* short-form 'file format' */
  569.  
  570.  
  571. /* more global variables, used by xv and xvmisc */
  572. WHERE byte          *cpic;         /* cropped version of pic */
  573. WHERE int           cWIDE, cHIGH,  /* size of cropped region */
  574.                     cXOFF, cYOFF;  /* offset of region from 0,0 of pic */
  575.  
  576. WHERE byte          *epic;         /* expanded version of cpic */
  577.                                    /* points to pic when at 1:1 expansion */
  578.                                    /* this is converted to 'theImage' */
  579. WHERE int           eWIDE, eHIGH;  /* size of epic */
  580. WHERE unsigned int  normFact;      /* factor to shrink picture by for 'norm' */
  581.  
  582. WHERE int           p_offx, p_offy;  /* offset of reparented windows */
  583. WHERE int           ch_offx,ch_offy; /* ChngAttr ofst for reparented windows */
  584.  
  585. WHERE byte           rorg[256], gorg[256], borg[256];  /* ORIGINAL colormap */
  586. WHERE byte           rcmap[256], gcmap[256], bcmap[256]; /*post-cmap-editing*/
  587. WHERE byte           rdisp[256],gdisp[256],bdisp[256];  /* DISPLAYED colors */
  588. WHERE byte           colAllocOrder[256];   /* order to allocate cols */
  589. WHERE unsigned long  freecols[256]; /* list of pixel values to free */
  590. WHERE byte           rwpc2pc[256]; /* mapping of shared pixels in -rw mode */
  591. WHERE int            nfcols;       /* number of colors to free */
  592. WHERE unsigned long  cols[256];    /* maps pic pixel values to X pixel vals */
  593. WHERE int            fc2pcol[256]; /* maps freecols into pic pixel values */
  594. WHERE int            numcols;      /* # of desired colors in picture */
  595.  
  596. WHERE byte           fsgamcr[256]; /* gamma correction curve (for FS dither) */
  597.  
  598.  
  599. WHERE XImage        *theImage;     /* X version of epic */
  600.  
  601.  
  602. WHERE int           ncols;         /* max # of (different) colors to alloc */
  603.  
  604. WHERE char          str[128],      /* dummy string used for error messages */
  605.                     basename[128]; /* 'nice' part of current filename */
  606.  
  607. WHERE int           bwidth,        /* border width of created windows */
  608.                     noglob,        /* force to only use colors it alloced */
  609.                     perfect,       /* perfect color.  install own colormap */
  610.                     fixedaspect,   /* fixed aspect ratio */
  611.                     slow24,        /* use slow 24to8 algorithm */
  612.                     ninstall,      /* true if using icccm-complaint WM
  613.                       (a WM that will does install CMaps */
  614.                     useroot,       /* true if we should draw in rootW */
  615.                     noqcheck,      /* true if we should NOT do QuickCheck */
  616.                     rwcolor,       /* true if we should use R/W color cells */
  617.                     rwthistime,    /* true if we DID use R/W color cells */
  618.                     owncmap,       /* true if we should always create cmap */
  619.                     epicmode,      /* either SMOOTH, DITH, or RAW */
  620.                     xerrcode;      /* errorcode of last X error */
  621.  
  622. WHERE float         defaspect,     /* default aspect ratio to use */
  623.                     normaspect;    /* normal aspect ratio of this picture */
  624.  
  625. WHERE int           crx1, cry1,    /* dimensions of cropping rectangle */
  626.                     crx2, cry2;
  627.  
  628. WHERE unsigned long rootbg, rootfg;   /* fg/bg for root border */
  629. WHERE int           waitsec;          /* secs btwn pics. -1=wait for event */
  630. WHERE int           waitloop;         /* loop at end of slide show? */
  631. WHERE int           automax;          /* maximize pic on open */
  632. WHERE int           rootMode;         /* mode used for -root images */
  633.  
  634. WHERE int           ctrlColor;        /* whether or not to use colored butts */
  635.  
  636. WHERE char         *def_str;          /* used by rd_*() routines */
  637. WHERE int           def_int;
  638.  
  639.  
  640. /* stuff used for 'info' box */
  641. WHERE Window        infoW;
  642. WHERE int           infoUp;       /* boolean:  whether infobox is visible */
  643. WHERE int           infoMode;
  644.  
  645.  
  646. /* stuff used for 'ctrl' box */
  647. WHERE Window        ctrlW;
  648. WHERE int           ctrlUp;       /* boolean:  whether ctrlbox is visible */
  649. WHERE char         *namelist[MAXNAMES];  /* list of file names from argv */
  650. WHERE char         *dispnames[MAXNAMES]; /* truncated names shown in listbox */
  651. WHERE int           numnames, curname;
  652. WHERE LIST          nList;
  653. WHERE BUTT          but[NBUTTS];         /* command buttons in ctrl window */
  654. WHERE Pixmap        grayTile, grayStip;  /* for drawing dim things */
  655. WHERE MBUTT         dispMB;              /* display mode menu button */
  656.  
  657.  
  658. /* stuff used for 'directory' box */
  659. WHERE Window        dirW, dnamW;
  660. WHERE int           dirUp;       /* is dirW mapped or not */
  661. WHERE LIST          dList;       /* list of filenames in current directory */
  662. WHERE BUTT          dbut[S_NBUTTS];
  663.  
  664.  
  665. /* stuff used for 'gamma' box */
  666. WHERE Window        gamW;
  667. WHERE int           gamUp;       /* is gamW mapped or not */
  668. WHERE BUTT          gbut[G_NBUTTS];
  669. WHERE int           editColor;   /* currently selected color # */
  670. WHERE int           hsvmode;     /* true if in HSVmode */
  671. WHERE int cellgroup[256], curgroup, maxgroup;  /* grouped colorcell stuff */
  672.  
  673. /* stuff used for 'ps' box */
  674. WHERE Window        psW;
  675. WHERE int           psUp;       /* is psW mapped, or what? */
  676.  
  677.  
  678. #ifdef HAVE_JPEG
  679. /* stuff used for 'jpeg' box */
  680. WHERE Window        jpegW;
  681. WHERE int           jpegUp;       /* is psW mapped, or what? */
  682. #endif
  683.  
  684.  
  685. #undef WHERE
  686.  
  687.  
  688.  
  689.  
  690.  
  691. /* function declarations for externally-callable functions */
  692.  
  693. #ifdef __STDC__ 
  694. /****************************** XV.C ****************************/
  695. void FixAspect(int, int *, int *);
  696. int  DeleteCmd(void);
  697. void HandleDispMode(void);
  698. char *lower_str(char *);
  699. int  rd_int(char *);
  700. int  rd_str(char *);
  701. int  rd_flag(char *);
  702.  
  703. /****************************** XVEVENT.C ****************************/
  704. int  EventLoop(void);
  705. int  HandleEvent(XEvent *, int *);
  706. void DrawWindow(int,int,int,int);
  707. void WResize(int, int);
  708. void WRotate(void);
  709. void WCrop(int, int);
  710. void WUnCrop(void);
  711. void GetWindowPos(XWindowAttributes *);
  712. void SetWindowPos(XWindowAttributes *);
  713. void InvCropRect(void);
  714. void SetEpicMode(void);
  715. int  xvErrorHandler(Display *, XErrorEvent *);
  716.  
  717. /****************************** XVROOT.C ****************************/
  718. void MakeRootPic(void);
  719. void ClearRoot(void);
  720. void SaverootInfo(void);
  721. void KillOldRootInfo(void);
  722.  
  723. /*************************** XVMISC.C ***************************/
  724. Window CreateWindow(char *, char *, unsigned int, unsigned int, 
  725.             unsigned long, unsigned long);
  726. void CenterString(Window, char *, int, int);
  727. void ULineString(Window, char *, int, int);
  728. int  StringWidth(char *);
  729. void FakeButtonPress(BUTT *);
  730. void DimRect(Window, int, int, int, int, u_long);
  731. void SetCropString(int);
  732. void Warning(void);
  733. void FatalError(char *);
  734. void Quit(int);
  735. void LoadFishCursors(void);
  736. void WaitCursor(void);
  737. void SetCursors(int);
  738. void Timer(int);
  739.  
  740. /*************************** XVCOLOR.C ***************************/
  741. void   SortColormap(void);
  742. void   AllocColors(void);
  743. void   AllocRWColors(void);
  744. Status xvAllocColor(Display *, Colormap, XColor *);
  745. void   xvFreeColors(Display *, Colormap, unsigned long *, int, unsigned long);
  746. void   FreeAllColors(void);
  747. void   ApplyEditColor(int);
  748.  
  749. /*************************** XVIMAGE.C ***************************/
  750. void Resize(int, int);
  751. void DoCrop(void);
  752. void UnCrop(void);
  753. void AutoCrop(void);
  754. void Rotate(int);
  755. void Flip(int);
  756. void FlipPic(byte *, int, int, int);
  757. void FSDither(byte *, int, int, byte *);
  758. void CreateXImage(void);
  759.  
  760. /*************************** XVSMOOTH.C ***************************/
  761. void  Smooth(void);
  762. byte *Smooth24(void);
  763. void ColorDither(byte *, int, int);
  764.  
  765. /*************************** XV24TO8.C **************************/
  766. void Init24to8(void);
  767. int  Conv24to8(byte *, int, int, int);
  768.  
  769. /**************************** XVCTRL.C **************************/
  770. void CreateCtrl(char *);
  771. void CtrlBox(int);
  772. void RedrawCtrl(int, int, int, int);
  773. int  ClickCtrl(int, int);
  774. void DrawCtrlStr(void);
  775. void ScrollToCurrent(LIST *);
  776.  
  777. void LSCreate(LIST *, Window, int, int, int, int, int, char **, int, 
  778.           unsigned long, unsigned long, void (*)(void), int, int);
  779. void LSRedraw(LIST *);
  780. int  LSClick (LIST *, XButtonEvent *);
  781. void LSNewData(LIST *, char **, int);
  782. void LSKey(LIST *, int);
  783.  
  784.  
  785. /*************************** XVINFO.C ***************************/
  786. void  CreateInfo(char *);
  787. void  InfoBox(int);
  788. void  RedrawInfo(int, int, int, int);
  789. void  SetInfoMode(int);
  790. void  SetISTR();
  791. char *GetISTR(int);
  792.  
  793. /**************************** XVDIR.C ***************************/
  794. void CreateDirW(char *);
  795. void DirBox(int);
  796. void RedrawDirW(int,int,int,int);
  797. int  ClickDirW(int, int);
  798. void LoadCurrentDirectory(void);
  799. void RedrawDDirW(void);
  800. void RedrawDNamW(void);
  801. void SelectDir(int);
  802. void TrackDDirW(int,int);
  803. int  DirKey(int);
  804. int  DoSave(void);
  805. void SetDirFName(char *);
  806. char *GetDirFName(void);
  807. void SetDirRButt(int, int);
  808. int  Globify(char *);
  809. FILE *OpenOutFile(char *);
  810. int  CloseOutFile(FILE *, char *, int);
  811. byte *HandleBWandReduced(int, int *, byte **, byte **, byte **);
  812.  
  813. /**************************** XVGAM.C **************************/
  814. void CreateGam(char *);
  815. int  GamCheckEvent(XEvent *);
  816. void GamBox(int);
  817. void NewCMap();
  818. void RedrawCMap();
  819. void ChangeEC(int);
  820. void ApplyECctrls(void);
  821. void GenerateFSGamma(void);
  822. void GammifyColors(void);
  823. void Gammify1(int);
  824. void rgb2hsv(int, int, int, double *, double *, double *);
  825. void hsv2rgb(double, double, double, int *, int *, int *);
  826.  
  827. /*************************** XVSCRL.C ***************************/
  828. void SCCreate  (SCRL *, Window, int, int, int, int, int, int, int, int, 
  829.                       unsigned long, unsigned long, void (*)(void));
  830. void SCSetRange(SCRL *, int, int, int, int);
  831. int  SCSetVal  (SCRL *, int);
  832. void SCRedraw  (SCRL *);
  833. void SCTrack   (SCRL *, int, int);
  834.  
  835.  
  836. /*************************** XVDIAL.C ***************************/
  837. void DCreate  (DIAL *, Window, int, int, int, int, int, int, int, int, 
  838.                       unsigned long, unsigned long, char *, char *);
  839. void DSetRange(DIAL *, int, int, int, int);
  840. void DSetVal  (DIAL *, int);
  841. void DSetActive(DIAL *, int);
  842. void DRedraw  (DIAL *);
  843. int  DTrack   (DIAL *, int, int);
  844.  
  845.  
  846. /**************************** XVBUTT.C ***************************/
  847.  
  848. void BTCreate(BUTT *, Window, int, int, int, int, char *, 
  849.           unsigned long, unsigned long);
  850. void BTSetActive(BUTT *, int);
  851. void BTRedraw(BUTT *);
  852. int  BTTrack (BUTT *);
  853.  
  854.  
  855. RBUTT *RBCreate(RBUTT *, Window, int, int, char*, 
  856.         unsigned long, unsigned long);
  857. void   RBRedraw(RBUTT *, int);
  858. void   RBSelect(RBUTT *, int);
  859. int    RBWhich(RBUTT *);
  860. int    RBCount(RBUTT *);
  861. void   RBSetActive(RBUTT *, int, int);
  862. int    RBClick(RBUTT *, int, int);
  863. int    RBTrack(RBUTT *, int);
  864.  
  865. void   CBCreate(CBUTT *, Window, int, int, char *, u_long, u_long);
  866. void   CBRedraw(CBUTT *);
  867. void   CBSetActive(CBUTT *, int);
  868. int    CBClick(CBUTT *,int,int);
  869. int    CBTrack(CBUTT *);
  870.  
  871. void   MBCreate(MBUTT *, Window, int, int, int, int, char *, 
  872.         char **, int, u_long, u_long);
  873. void   MBRedraw(MBUTT *);
  874. void   MBSetActive(MBUTT *, int);
  875. int    MBClick(MBUTT *, int, int);
  876. int    MBTrack(MBUTT *);
  877.  
  878.  
  879. /**************************** XVGRAF.C ***************************/
  880. void   CreateGraf(GRAF *, Window, int, int, u_long, u_long, char *);
  881. void   InitGraf  (GRAF *);
  882. void   RedrawGraf(GRAF *, int, int, int, int);
  883. int    ClickGraf (GRAF *, Window, int, int);
  884. int    GrafKey   (GRAF *, char *);
  885. void   GenerateGrafFunc(GRAF *, int);
  886. void   Graf2Str  (GRAF_STATE *, char *);
  887. int    Str2Graf  (GRAF_STATE *, char *);
  888. void   GetGrafState (GRAF *, GRAF_STATE *);
  889. int    SetGrafState (GRAF *, GRAF_STATE *);
  890. void   InitSpline(int *, int *, int, double *);
  891. double EvalSpline(int *, int *, double *, int, double);
  892.  
  893.  
  894. /**************************** XVGIF.C ***************************/
  895. int LoadGIF(char *, int);
  896.  
  897. /*************************** XVGIFWR.C **************************/
  898. int WriteGIF(FILE *, byte *, int, int, byte *, byte *, byte *, int, int);
  899.  
  900. /**************************** XVPM.C ****************************/
  901. int LoadPM(char *, int);
  902. int WritePM(FILE *, byte *, int, int, byte *, byte *, byte *, int, int);
  903.  
  904. /**************************** XVPBM.C ***************************/
  905. int LoadPBM(char *, int);
  906. int WritePBM(FILE *, byte *, int, int, byte *, byte *, byte *, int, int, int);
  907.  
  908. /**************************** XVXBM.C ***************************/
  909. int LoadXBM(char *, int);
  910. int WriteXBM(FILE *, byte *, int, int, char *);
  911.  
  912. /**************************** XVSUNRAS.C ***************************/
  913. int LoadSunRas(char *, int);
  914. int WriteSunRas(FILE *, byte *, int, int, byte *, byte *, byte*, 
  915.         int, int, int);
  916.  
  917. /**************************** XVJPEG.C ***************************/
  918. int  LoadJFIF(char *, int);
  919. void CreateJPEGW(void);
  920. void JPEGDialog(int);
  921. int  JPEGCheckEvent(XEvent *);
  922. void JPEGSaveParams(char *, int);
  923.  
  924. /*************************** XVPS.C ***************************/
  925. void  CreatePSD(char *);
  926. void  PSDialog(int);
  927. int   PSCheckEvent(XEvent *);
  928. void  PSSaveParams(char *, int);
  929. void  PSResize(void);
  930.  
  931. /*************************** XVPOPUP.C ***************************/
  932. void  CenterMapWindow(Window, int, int, int, int);
  933. int   PopUp(char *, char **, int);
  934. void  OpenAlert(char *);
  935. void  CloseAlert();
  936. int   PSCheckEvent(XEvent *);
  937. void  TextRect(Window, char *, int, int, int, int, u_long);
  938.  
  939. /*************************** XVDFLT.C ***************************/
  940. void LoadDfltPic();
  941. void xbm2pic(char *, int, int, byte *, int, int, int, int, int);
  942.  
  943.  
  944.  
  945. #else     /* using non-ANSI cc.  Function defs, but no params */
  946.  
  947.  
  948.  
  949.  
  950. /****************************** XV.C ****************************/
  951. void FixAspect(), HandleDispMode();
  952. int  DeleteCmd(), rd_int(), rd_str(), rd_flag();
  953. char *lower_str();
  954.  
  955. /****************************** XVEVENT.C ****************************/
  956. int  EventLoop(), HandleEvent();
  957. void DrawWindow(), WResize(), WRotate(), WCrop(), WUnCrop();
  958. void GetWindowPos(), SetWindowPos(), InvCropRect(), SetEpicMode();
  959. int  xvErrorHandler();
  960.  
  961. /****************************** XVROOT.C ****************************/
  962. void MakeRootPic(), ClearRoot(), KillOldRootInfo(), SaveRootInfo();
  963.  
  964. /*************************** XVMISC.C ***************************/
  965. Window CreateWindow();
  966. int    StringWidth();
  967. void   CenterString(), ULineString(), FakeButtonPress(), DimRect();
  968. void   SetCropString(), Warning(), FatalError(), Quit();
  969. void   LoadFishCursors(), WaitCursor(), SetCursors(), Timer();
  970.  
  971. /*************************** XVCOLOR.C ***************************/
  972. Status xvAllocColor();
  973. void   SortColormap(), AllocColors(), AllocRWColors();
  974. void   xvFreeColors(), FreeAllColors(), ApplyEditColor();
  975.  
  976. /*************************** XVIMAGE.C ***************************/
  977. void Resize(), DoCrop(), UnCrop(), AutoCrop(), Rotate(), Flip();
  978. void FlipPic(), FSDither(), CreateXImage();
  979.  
  980. /*************************** XVSMOOTH.C ***************************/
  981. void Smooth(), ColorDither();
  982. byte *Smooth24();
  983.  
  984. /*************************** XV24TO8.C **************************/
  985. void Init24to8();
  986. int  Conv24to8();
  987.  
  988. /**************************** XVCTRL.C **************************/
  989. void CreateCtrl(), CtrlBox(), RedrawCtrl(), DrawCtrlStr(), ScrollToCurrent();
  990. int  ClickCtrl();
  991.  
  992. void LSCreate(), LSRedraw(), LSNewData(), LSKey();
  993. int  LSClick();
  994.  
  995. /*************************** XVINFO.C ***************************/
  996. void  CreateInfo(), InfoBox(), RedrawInfo(), SetInfoMode(), SetISTR();
  997. char *GetISTR();
  998.  
  999. /**************************** XVDIR.C ***************************/
  1000. void CreateDirW(), DirBox(), RedrawDirW(), LoadCurrentDirectory();
  1001. int  ClickDirW(), DoSave(), DirKey();
  1002. void RedrawDDirW(), RedrawDNamW(), SelectDir(), TrackDDirW();
  1003. void SetDirFName(), SetDirRButt();
  1004. char *GetDirFName();
  1005. int  Globify(), CloseOutFile();
  1006. FILE *OpenOutFile();
  1007. byte *HandleBWandReduced();
  1008.  
  1009. /**************************** XVGAM.C **************************/
  1010. void CreateGam();
  1011. int  GamCheckEvent();
  1012. void GamBox(), NewCMap(), RedrawCMap();
  1013. void ChangeEC(), ApplyECctrls();
  1014. void GenerateFSGamma(), GammifyColors();
  1015. void Gammify1(), rgb2hsv(), hsv2rgb();
  1016.  
  1017. /*************************** XVSCRL.C ***************************/
  1018. void SCCreate(), SCSetRange(), SCRedraw(), SCTrack();
  1019. int SCSetVal();
  1020.  
  1021. /*************************** XVDIAL.C ***************************/
  1022. void DCreate(), DSetRange(), DSetVal(), DRedraw(), DSetActive();
  1023. int  DTrack();
  1024.  
  1025. /**************************** XVBUTT.C ***************************/
  1026. void BTCreate(), BTSetActive(), BTRedraw();
  1027. int  BTTrack();
  1028.  
  1029. RBUTT *RBCreate();
  1030. void   RBRedraw(), RBSelect(), RBSetActive();
  1031. int    RBWhich(), RBCount(), RBClick(), RBTrack();
  1032.  
  1033. void CBCreate(), CBRedraw(), CBSetActive();
  1034. int  CBClick(), CBTrack();
  1035.  
  1036. void MBCreate(), MBRedraw(), MBSetActive();
  1037. int  MBClick(), MBTrack();
  1038.  
  1039.  
  1040. /*************************** XVGRAF.C ***************************/
  1041. void   CreateGraf(), InitGraf(), RedrawGraf(), GenerateGrafFunc();
  1042. void   Graf2Str(), GetGrafState(), InitSpline();
  1043. int    ClickGraf(), GrafKey(), Str2Graf(), SetGrafState();
  1044. double EvalSpline();
  1045.  
  1046.  
  1047. /**************************** XVGIF.C ***************************/
  1048. int LoadGIF();
  1049.  
  1050. /*************************** XVGIFWR.C **************************/
  1051. int WriteGIF();
  1052.  
  1053. /**************************** XVPM.C ****************************/
  1054. int LoadPM(), WritePM();
  1055.  
  1056. /**************************** XVPBM.C ***************************/
  1057. int LoadPBM(), WritePBM();
  1058.  
  1059. /**************************** XVXBM.C ***************************/
  1060. int LoadXBM(), WriteXBM();
  1061.  
  1062. /**************************** XVSUNRAS.C ***************************/
  1063. int LoadSunRas(), WriteSunRas();
  1064.  
  1065. /**************************** XVJPEG.C ***************************/
  1066. int LoadJFIF(), JPEGCheckEvent();
  1067. void CreateJPEGW(), JPEGDialog(), JPEGSaveParams();
  1068.  
  1069. /*************************** XVPS.C ***************************/
  1070. void  CreatePSD(), PSDialog(), PSSaveParams(), PSResize();
  1071. int   PSCheckEvent();
  1072.  
  1073. /*************************** XVPOPUP.C ***************************/
  1074. void CenterMapWindow(), OpenAlert(), CloseAlert();
  1075. int  PopUp(), PUCheckEvent();
  1076. void TextRect();
  1077.  
  1078. /*************************** XVDFLT.C ***************************/
  1079. void LoadDfltPic(), xbm2pic();
  1080.  
  1081. #endif
  1082.